package com.cyandpos.pad.sale.adapter;

import android.app.Activity;
import androidx.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.cyandpos.pad.R;
import com.cyandpos.pad.posdata.Goods;

import java.util.List;

/**
 * 默认商品适配器
 */
public class DefaultGoodAdapter extends BaseQuickAdapter<Goods, BaseViewHolder> {
    private Activity activity;
    public DefaultGoodAdapter(int layoutResId, @Nullable List<Goods> data,Activity activity) {
        super(layoutResId, data);
        this.activity = activity;
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, Goods goods) {
        TextView tvCode = baseViewHolder.getView(R.id.tv_defaultgoods_code);
        TextView tvName = baseViewHolder.getView(R.id.tv_defaultgoods_name);
        tvCode.setText(goods.getCode());
        if(goods.getName().length()>12){
            tvName.setText(goods.getName().substring(0,10)+"……");
        }else{
            tvName.setText(goods.getName());
        }


    }
}
